// 应用场景
import { GetApplicationInfoList } from "@/request/applicationinfo"
import { useEffect, useState } from "react"

export default function useUsageScenario () {
    const [ selectOptions, setSelectOptions ] = useState<Array<Record<string,unknown>>>([])
    const getData = async () => {
        const { code, data } = await GetApplicationInfoList({
            limit: 1000,
            page: 1
        }  as any)
        if ( code === 200 ) {
            setSelectOptions( data?.list.map((item: { appCode: any; appName: any })=>{
                return {
                    ...item,
                    label: item.appName,
                    value: item.appCode
                }
            }) )
        } else {
            setSelectOptions( [] )
        }
    }
    useEffect( () => {
        getData()
    }, [] )
    return selectOptions
}